<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>商品退款</title>
</head>
<body class="fixed-sidebar full-height-layout gray-bg">
<div id="main_send_good">
<input type="hidden" id="orderIds" value="${orderIds}"/>
<table class="table table-striped table-bordered" style="margin-right: 20px;">
		    <thead class="js-freight-cost-list-header">
		            <tr>
		                <td>商品</td>
		                <td>数量</td>
		                <td>金额（元）</td>
		            </tr>
		    </thead>
		    <tbody>
		     [#list orderDetailResultDto as ResultDto]
                  [#list ResultDto.orderItems as items]
				    <tr>
						<td><img src="${items.productImg}" style="margin: 2px" width="30" height="30" number="1"><br/>${items.productName}</td>
						<td>${items.quantity}</td>
						<td>${items.totalPrice}</td>
					</tr>
			     [/#list]
			[/#list]
            </tbody>
		</table>
         <div style="margin-top: 40px;">
                   <label class="col-md-2 control-label">退款金额:</label>
                   <div>
                   <div  id="error_cash">
	                <input type="text" id="cash" name="cash" class="form-control" value="" style="width:180px;" onkeyup="this.value=this.value.replace(/[^\d.]/g,'')"/>
	                <label class="error_cash" style="color:red;" for="cash"></label>
	            </div>
                   </div>
         </div>
         <br/>
         <div style="margin-top: 40px;">
                   <label class="col-md-2 control-label">退款标识<i class="fa fa-question-circle" onmouseout="layer.closeAll();" onmouseover="layer.tips('提供给微信后台退款标识。', this, {tips: [1, '#3595CC'],time: 0});"></i></label>
                   <div>
                    [#list orderDetailResultDto as ResultDto]
	                <input type="text" id="transactionId" name="transactionId" class="form-control" value="${ResultDto.transactionId}" style="width:180px;"  readonly="readonly"/>
	                [/#list]
                   </div>
         </div>
         
         <div class="panel-default">
		  	<div class="panel-body" align="right">
				<button type="button" onclick="refund();" class="btn btn-primary btn-sm">确认退款</button>
		  	</div>
	  	</div>
</div>	  	
<script type="text/javascript">
function refund(){
	clearError()
	var params={}, error = {};
	var orderIds = $("#orderIds").val(), cash = $("#cash").val(),transactionId=$("#transactionId").val();
	params.orderIds = $.trim(orderIds);
	params.transactionId = $.trim(transactionId);
	if($.trim(cash) =="") {error.error_cash = "快递单号不能为空"; } else {error.cash=""; params.cash = $.trim(cash);}
	var hasError = false;
	for(var key in error){
		if(error[key]!=""){
			if(!hasError) hasError = true;
			$("#"+key).addClass("has-error");
			$("#"+key).find("label").text(error[key]);
		}else{
			$("#"+key).removeClass("has-error");
			$("#"+key).find("label").empty();
		}
	}
	if(hasError) return false;
	$("#main_send_good").mask("正在退款...");
	$.post(obz.ctx+"/order/saveRefund", params, function(json) {
		$("#main_send_good").unmask();
		 if(json.code!=200){
			BootstrapDialog.alert({title:'提示', message:json.msg});
		}else{
			obz.msg('退款成功', function(){
				location.reload();
			});					
		}
},"json");
}

function clearError(){
	$(".error_cash").empty();
	var cash=$("input[name='cash']");
	cash.css("border-color", "");
}
</script>
</body>
</html>        